using UnityEngine;
using System.Collections;

public class Spawner : MonoBehaviour {
	
	public GameObject naveR1;
	public GameObject naveR2;
	public GameObject naveR3;
	public GameObject naveR4;
	
	float temp = 0;
	float tempTriger = 4;
	int rand;
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		temp += 1 * Time.deltaTime;
		if (temp > tempTriger){
			temp = 0;
			tempTriger -= 0.1f;
			rand = Random.Range(0,4);
			if (rand < 1){
				rand = Random.Range(-20,20);
				GameObject.Instantiate(naveR1, 
					new Vector3(rand, this.transform.position.y, 300), 
					Quaternion.identity
					);
			}
			else if (rand >=1 && rand < 2){
				rand = Random.Range(-20,20);
				GameObject.Instantiate(naveR2, 
					new Vector3(rand, this.transform.position.y, 300), 
					Quaternion.identity
					);
			}
			else if (rand >=2 && rand < 3){
				rand = Random.Range(-20,20);
				GameObject.Instantiate(naveR3, 
					new Vector3(rand, this.transform.position.y, 300), 
					Quaternion.identity
					);
			}
			else {
				rand = Random.Range(-20,20);
				GameObject.Instantiate(naveR4, 
					new Vector3(rand, this.transform.position.y, 300), 
					Quaternion.identity
					);
			}
		}
	}
}
